#include<stdio.h>
#include<time.h>

char* get_current_utc_time_str();
int main()
{
 
    unsigned int timezone = 0;
    time_t t1, t2 ;
    struct tm *tm_local, *tm_utc;
 
	time(&t1);
	t2 = t1;
	tm_local = localtime(&t1);
	t1 = mktime(tm_local) ;
	
	tm_utc = gmtime(&t2);
	t2 = mktime(tm_utc);
	
    timezone = (t1 - t2) / 3600;
	printf("%d\n", timezone);
 
	tm_local = localtime(&t1);

	printf("this \'utc to local\',make \'local to utc\' by yourself\n");

	printf("local time=%d-%02d-%02dT%02d:%02d:%02d.000%+03d\n", 
			1900+tm_local->tm_year,1+tm_local->tm_mon,tm_local->tm_mday,
			tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec,1000*timezone);

	char time_str[28];
	sprintf(time_str,"%d-%02d-%02dT%02d:%02d:%02d.000%+03d\n", 
			1900+tm_local->tm_year,1+tm_local->tm_mon,tm_local->tm_mday,
			tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec,1000*timezone);
	printf("time_str=%s",time_str);
	
	char date_str[11];
	int i = 0;
	for(i=0;i<10;i++){
		date_str[i]=time_str[i];
	}
	date_str[10]='\0';
	printf("date_str=%s\n",date_str);

	char datetime_str[20];
	
	for(i=0;i<19;i++){
		if(i!=10)
			datetime_str[i]=time_str[i];
		else
			datetime_str[i]=' ';
	}
	
	date_str[20]='\0';
	printf("datetime_str=%s\n",datetime_str);
	char* a= get_current_utc_time_str();
	printf("-----------  %s",a);
	return 0;
}

char* get_current_utc_time_str()
{

    time_t t1;
    struct tm *tm_utc;
	tm_utc = gmtime(&t1);
	//ti = mktime(tm_utc);

	char time_str[28];
	sprintf(time_str,"%d-%02d-%02dT%02d:%02d:%02d.000%+03d\n", 
			1900+tm_utc->tm_year,1+tm_utc->tm_mon,tm_utc->tm_mday,
			tm_utc->tm_hour, tm_utc->tm_min, tm_utc->tm_sec,1000*timezone);
}

